<template>
    <div>
        <users :title="'注册'"></users>
          <yd-cell-group>
        <yd-cell-item>
            <yd-input slot="right" required ref="phone" v-model="input1" regex="mobile" placeholder="手机号"></yd-input>
        </yd-cell-item>
         <yd-cell-item>
            <yd-input slot="right"  required type="text" ref="nicname"  max="10" min="3" v-model="input2" placeholder="昵称(3-10)"></yd-input>
        </yd-cell-item>
        <yd-cell-item>
            <yd-input slot="right" type="password" ref="surepwd" v-model="input3" max="20" min="6" placeholder="密码(6-20)"></yd-input>
        </yd-cell-item>
        <yd-cell-item>
            <yd-input slot="right" type="password" ref="pwd" v-model="input4" max="20" min="6" placeholder="再输入密码(6-20)"></yd-input>
        </yd-cell-item>
        </yd-cell-group>
         <yd-button-group>
       <yd-button size="large" type="primary" bgcolor="#f37d0f" color="#fff" shape="circle" @click.native="userheader">注册</yd-button>
        </yd-button-group>



    </div>
</template>
<script>
import users from '../pulic/user-header.vue'
export default {
    data() {
        return {
            input1:"",
            input2:"",
            input3:"",
            input4:""
        }
    },
      beforeRouteEnter (to, from, next) {
        next(vm =>{
           // vm.$emit("footerTitle",false)
           vm.$parent.$data.showfooter=false
           vm.$parent.$data.showmenu=false
        })
    },
    beforeRouteLeave (to, from, next) {
            this.$parent.$data.showfooter=true
            this.$parent.$data.showmenu=true
           next()
    },
    components:{
        users
    },
    methods: {
        userheader(){
       if(this.$refs.phone.valid && this.$refs.nicname.valid && this.$refs.surepwd.valid && this.$refs.pwd.valid){
           if(this.input3==this.input4){
                this.$dialog.toast({
                   mes:"注册成功",
                   timeout:1500,
                   icon: 'success',
                   callback:()=>{
                       this.$router.push({name:"login"})
                   }
               })
            
           }else{
               this.$dialog.toast({
                   mes:"密码不一致",
                   timeout:1500
               })
           }
       }else{

       }  
        }
    },
}
</script>
<style scoped>

</style>


